package org.cometmi.gwt.chat.client;

import org.cometmi.gwt.shared.exceptions.NameParseException;
import org.cometmi.gwt.shared.exceptions.NotAllowedQueueException;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.RootPanel;

public class Chat implements EntryPoint
{
	private LoginWidget login;

	@Override
	public void onModuleLoad()
	{
		login = new LoginWidget(new ClickHandler()
		{
			@Override
			public void onClick(ClickEvent event)
			{
				try
				{
					MessengerWidget messenger = new MessengerWidget(login.getUserName());
					RootPanel.get().remove(login);
					RootPanel.get().add(messenger);
				}
				catch (NameParseException e)
				{}
				catch (NotAllowedQueueException e)
				{}
			}
		});
		RootPanel.get().add(login);
	}
}
